package test46;

import java.io.*;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ws
 * Date: 2023-05-18
 * Time: 16:19
 */
//LinkedHashMap 顺序插入的哈希表
public class Main1 {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String str = null;
        Map<String, Integer> lHM = new LinkedHashMap<>();
        while ((str = br.readLine()) != null) {
            int last = str.lastIndexOf("\\");
            int end = str.lastIndexOf(" ") - 1;
            if (end - last > 16) {
                str = str.substring(end - 16 + 1);
            } else {
                str = str.substring(last + 1);
            }
            lHM.put(str, lHM.getOrDefault(str, 0) + 1);
        }
        int cnt = 0;
        for (Map.Entry<String, Integer> entry : lHM.entrySet()) {
            if (lHM.size() - cnt <= 8) {
                bw.write(entry.getKey() + " " + entry.getValue() + "\n");
            }
            cnt++;
        }
        bw.flush();
        bw.close();
        br.close();
    }
}
